package com.treasury.glasses.domain;

import com.treasury.glasses.Main;
import java.io.Serializable;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;

/**
 * ProgramUser for persistence.
 * @author <a href="mailto:glasses@audienz.eu">Jean-Luc Burot</a>
 */

@Entity
@NamedQueries({
    @NamedQuery(name = ProgramUser.COUNT_PROGRAMUSER, query = "SELECT COUNT(pu) FROM ProgramUser pu WHERE pu.username = :username"),
    @NamedQuery(name = ProgramUser.CHECK_USER, query = "SELECT pu FROM ProgramUser pu WHERE pu.username = :username"),
    @NamedQuery(name = ProgramUser.CHECK_USER_PASS, query = "SELECT pu FROM ProgramUser pu WHERE pu.username = :username AND pu.password = :password")
})
public class ProgramUser implements Serializable {
    /**
     * Serial Id.
     */
    private static final long serialVersionUID = 1L;
    
    /**
     * Prefix for the NamedQuery name.
     */
    private static final String PREFIX = "ProgramUser.";
    
    /**
     * Name to identify the desired NamedQuery in service classes.
     */
    public static final String COUNT_PROGRAMUSER = PREFIX + "countProgramUser";
    
     /**
     * Name to identify the desired NamedQuery in service classes.
     */
    public static final String CHECK_USER = PREFIX + "checkUser";
    
     /**
     * Name to identify the desired NamedQuery in service classes.
     */
    public static final String CHECK_USER_PASS = PREFIX + "checkUserPass";
    
    /**
     * Id field.
     */
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    
    /**
     * ActivityLog field.
     */
    @OneToMany(mappedBy = "programUser")
    private List<ActivityLog> activityLog;
    
    /**
     * Username field.
     */
    @Column(length = Main.TEXTFIELD_MAXLENGTH)
    private String username;
    
    /**
     * First name field.
     */
    @Column(length = Main.TEXTFIELD_MAXLENGTH)
    private String firstName;
    
    /**
     * Last name field.
     */
    @Column(length = Main.TEXTFIELD_MAXLENGTH)
    private String lastName;
    
    /**
     * Password field.
     */
    @Column(length = Main.TEXTFIELD_MAXLENGTH)
    private String password;
    
    /**
     * Gets the id.
     * @return Id
     */
    public Long getId() {
        return id;
    }
    
    /**
     * Sets the id.
     * @param id Id
     */
    public void setId(final Long id) {
        this.id = id;
    }
    
    /**
     * Gets the activity log.
     * @return ActivityLog
     */
    public List<ActivityLog> getActivityLog() {
        return activityLog;
    }
    
    /**
     * Sets the activity log.
     * @param activityLog 
     */
    public void setActivityLog(List<ActivityLog> activityLog) {
        this.activityLog.addAll(activityLog);
    }
    
    
    /**
     * Add an activity log.
     * @param activityLog 
     */
    public void addActivityLog(ActivityLog activityLog) {
        this.activityLog.add(activityLog);
    }
    
    /**
     * Gets the username.
     * @return Username
     */
    public String getUsername() {
        return username;
    }
    
    /**
     * Sets the username.
     * @param username Username
     */
    public void setUsername(final String username) {
        this.username = username;
    }
    
    /**
     * Gets the first name.
     * @return First name
     */
    public String getFirstName() {
        return firstName;
    }
    
    /**
     * Sets the first name.
     * @param firstName First name
     */
    public void setFirstName(final String firstName) {
        this.firstName = firstName;
    }
    
    /**
     * Gets the last name.
     * @return last name
     */
    public String getLastName() {
        return lastName;
    }
    
    /**
     * Sets the last name.
     * @param lastName Last name
     */
    public void setLastName(final String lastName) {
        this.lastName = lastName;
    }
    
    /**
     * Gets the password.
     * @return Password
     */
    public String getPassword() {
        return this.password;
    }
    
    /**
     * Sets the password.
     * @param password Password
     */
    public void setPassword(final String password) {
        this.password = password;
    }
}
